import java.util.Scanner;

public class Demo12 {
    public static void main(String[] args) {
        Object locker = new Object();
        Thread t1 = new Thread(() -> {
            synchronized (locker) {
                System.out.println("t1 wait 之前");
                try {
                    locker.wait();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println("t1 wait 之后");
            }
        });
        Thread t2 = new Thread(() -> {
            synchronized (locker){
                System.out.println("t2 notify之前");
                locker.notify(); //告诉他不用死等了，等我释放这把锁你就可以拿了~~
                Scanner scanner = new Scanner(System.in);
                scanner.nextInt();
                System.out.println("t2 notify之后");
                scanner.nextInt();
            }
        });
        t1.start();
        t2.start();
    }
}
